package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortListDemo3 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("王克晶老师");
        list.add("范传奇");
        list.add("刘桑");
        System.out.println(list);
        //Collections.sort(list);
        Collections.sort(list,new Comparator<String>() {
            public int compare(String o1, String o2) {
                int len1 = o1.length();
                int len2 = o2.length();
                return len1 - len2;
            }
        });
        System.out.println(list);









        /*
        list.add("Tom");
        list.add("rose");
        list.add("jack");
        list.add("Jerry");
        list.add("james");
        list.add("java");
        System.out.println(list);
        Collections.sort(list);
        System.out.println(list);

         */

    }
}
